package com.zhuchaooasystem.utils;

import java.util.Random;

/**
 * @author yinsi
 *         <p/>
 *         随机数工具类
 */
public class RandomUtils {

    /**
     * 随机生成四位数
     *
     * @return
     */
    public static int getRandomNumberFour() {
        return (int) (Math.random() * 9000 + 1000);
    }

    /**
     * 随机生成七个字母
     *
     * @return
     */
    public static String getRandomLetter(int length) {
        String randomLetter = "";
        try {
            String s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
            char[] c = s.toCharArray();
            Random random = new Random();
            for (int i = 0; i < length; i++) {
                randomLetter += c[random.nextInt(c.length)];
            }
        } catch (Exception e) {
        }
        return randomLetter;
    }


}
